//
//  SideBarViewController.m
//  YanMusicPlayer
//
//  Created by 1564335 on 15-6-11.
//  Copyright (c) 2015年 胡岩 All rights reserved.
//

#import "SideBarViewController.h"
#import "MainListViewController.h"
#import "ClassListViewController.h"
#import "RankingListViewController.h"
#import "SongListViewController.h"
#import "MineViewController.h"
@interface SideBarViewController ()<CDSideBarControllerDelegate>

@end

@implementation SideBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSArray *imageList = @[[UIImage imageNamed:@"iconfont-zhuye"],
                                            [UIImage imageNamed:@"iconfont-bang"],
                                            [UIImage imageNamed:@"iconfont-rencaikufenlei"],
                                            [UIImage imageNamed:@"iconfont-bofangliebiao"], [UIImage imageNamed:@"iconfont-wode"]];
    
    self.sideBar = [[CDSideBarController alloc] initWithImages:imageList];
    self.sideBar.delegate = self;
    MainListViewController *mainListVC = [[MainListViewController alloc] init];
    ClassListViewController *MvListVC = [[ClassListViewController alloc] init];
    RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
    SongListViewController *songList = [[SongListViewController alloc] init];
    MineViewController *mineView = [[MineViewController alloc] init];
    
    self.viewControllers = @[mainListVC, rankingListVC, MvListVC, songList, mineView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.tabBar.hidden = YES;
    for (UIView *child in self.tabBar.subviews) {
        if ([child isKindOfClass:[UIControl class]]) {
            [child removeFromSuperview];
        }
    }
    [_sideBar insertMenuButtonOnView:self.view atPosition:CGPointMake(self.view.frame.size.width - 45, 30 * (_HEIGHT / _DEFAULT_HEIGHT))];
}

- (BOOL)canBecomeFirstResponder
{
    return YES;
}

#pragma mark - CDSidebar Delegate
-(void)menuButtonClicked:(int)index{
    self.selectedIndex = index;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
